﻿using server.filters;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Sockets;
using System.Text;
using System.Threading.Tasks;

namespace CommunicationProtocol.filters
{
    /**
     * 使用 socket 来发送接收到的字节数据
     */ 
    public class SocketSenderFilter : NetFilter
    {
        Socket socket;
        public SocketSenderFilter(Socket socket) {
            this.socket = socket;
        }
        public void invoke(object buffer, InvocationChain invocationChain)
        {
            if (!(buffer is byte[])) {
                throw new ArgumentException("socket不支持发送"+buffer.GetType());
            }

            byte[] sendingData = (byte[])buffer;


            socket.Send(sendingData);
        }
    }
}
